<!DOCTYPE html>
<html lang="en">
  <head>
    <meta charset="UTF-8" />
    <meta name="viewport" content="width=device-width, initial-scale=1.0" />
    <title>对象方法扩展</title>
  </head>
  <body>
    <script>
      // 1. Object.is 比较两个值是否严格相等，与『===』行为基本一致（+0 与 NaN）
      console.log(Object.is(1, 1.0)); // true
      console.log(Object.is(NaN, NaN)); // true
      console.log(NaN === NaN); // false
      // 2. Object.assign 对象的合并，将源对象的所有可枚举属性，复制到目标对象
      const config1 = {
        host: "localhost",
        port: 3306,
        name: "root",
        pass: "root",
        one: 1,
      };
      const config2 = {
        host: "127.0.0.1",
        port: 80,
        name: "admin",
        pass: "admin",
        tow: 2,
      };
      // Object.assign(被覆盖,覆盖);
      console.log(Object.assign(config1, config2)); //两者进行合并 config2会覆盖config1内的同名属性
      // 3.  __ proto__、setPrototypeOf、 setPrototypeOf 可以直接设置对象的原型
      const school = {
        name: "xx",
      };
      const cities = {
        xiaoqu: ["北京", "上海", "深圳"],
      };
      // 为school设置原型 将cities内容作为school的原型
      Object.setPrototypeOf(school, cities);
      // 获取原型
      console.log(Object.getPrototypeOf(school));
      console.log(school);
    </script>
  </body>
</html>
